<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>宝石与石头</title>
</head>
<body>
  <script>
    function fn(J, S) {
      const set = new Set()
      for (const s of J) {
        set.add(s)
      }
      let ans = 0
      for (const s of S) {
        if (set.has(s)) {
          ans++
        }
      }
      return ans
    }
    console.log(fn('aA', 'aAAbbbb'))
  </script>
</body>
</html>